var mongoose = require('mongoose');
require('../model/user.js');

module.exports = function(app){
    app.get('/reg', function(req, res){
		res.render('reg');
	});
    app.post('/reg', function(req, res){
        console.log(req.body)
		var User = mongoose.model('User');
		var u = new User({
			name: req.body.name,
			email: req.body.email,
			password: req.body.password
		})
		console.log(u.name);
		u.save();
		res.send({'code': 200});
    });
	app.get('/test', function(req, res){
		var User = mongoose.model('User');
		User.findOne({
			'email': 'a'
		}, function(err, u){
			console.log(u);
			res.send(u.name);
		});
	});
};
